package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.app.AppUserLoginDB;
import com.ruoyi.service.app.UserService;
import com.ruoyi.system.dto.AppUpdateUserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/app/user")
@Slf4j
public class UserController extends BaseController {

    @Resource
    private UserService userService;

    @GetMapping("/getUserInfo")
    public AjaxResult getUserInfo() {
        AppUserLoginDB appUserLoginDB = userService.getUserInfo();
        return AjaxResult.success(appUserLoginDB);
    }


    // 更改用户头像和昵称
    @PostMapping("/updateUserInfo")
    public AjaxResult updateUser(@RequestBody AppUpdateUserInfo dto) {
        userService.updateUserInfo(dto);
        return AjaxResult.success();
    }


}
